//
//  ActorTableViewCell.m
//  CapriceMusic
//
//  Created by dllo on 16/1/9.
//  Copyright © 2016年 MYX. All rights reserved.
//

#import "ActorTableViewCell.h"

@implementation ActorTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.userImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.userImage.layer.cornerRadius = 30;
        self.userImage.contentMode = UIViewContentModeScaleAspectFill;
        self.userImage.clipsToBounds = YES;
        [self addSubview:self.userImage];
        
        self.userName = [[UILabel alloc] initWithFrame:CGRectZero];
        self.userName.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.userName];
        
        self.videoCount = [[UILabel alloc] initWithFrame:CGRectZero];
        self.videoCount.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.videoCount];
        
        self.subCount = [[UILabel alloc] initWithFrame:CGRectZero];
        self.subCount.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.subCount];
        
        self.starImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self addSubview:self.starImage];
        
        self.heartImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self addSubview:self.heartImage];
    }
    return self;
}

- (void)setActorModel:(ActorModel *)actorModel {
    if (_actorModel != actorModel) {
        _actorModel = actorModel;
    }
    
    [self.userImage sd_setImageWithURL:[NSURL URLWithString:actorModel.smallAvatar]];
    
    self.userName.text = actorModel.name;
    
    self.videoCount.text = [NSString stringWithFormat:@"%@  首MV", actorModel.videoCount.stringValue];
    
    self.subCount.text = [NSString stringWithFormat:@"%@ 个人订阅", actorModel.subCount.stringValue];
    
    self.starImage.image = [UIImage imageNamed:@"star"];
    
    self.heartImage.image = [UIImage imageNamed:@"heart"];
}

- (void)layoutSubviews {
    [super layoutSubviews];

    self.userImage.frame = CGRectMake(10, 10, 60, 60);
    
    self.userName.frame = CGRectMake(self.userImage.right + 10, 10, 300, 10);
    
    self.videoCount.frame = CGRectMake(self.userImage.right + 20, self.userName.bottom + 10, 300, 10);
    
    self.subCount.frame = CGRectMake(self.videoCount.origin.x, self.videoCount.bottom + 10, 300, 10);
    
    self.starImage.frame = CGRectMake(self.userName.origin.x, self.videoCount.origin.y, 10, 10);
    
    self.heartImage.frame = CGRectMake(self.starImage.origin.x, self.subCount.origin.y, 10, 10);
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
